@echo off

set "BC_PATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Microsoft/VC/v160/BuildCustomizations"

mkdir "%BC_PATH%\temp"
rem Move all cuda files from BuildCustomizations folder to temp folder
for /r "%BC_PATH%" %%F in (*cuda*.xml *cuda*.props *cuda*.targets) do move "%%F" "%BC_PATH%\temp"
rem Move files containing 11.1 from temp folder to parent folder, so only 11.1 build files remain
for /r "%BC_PATH%\temp" %%F in (*11.1*) do copy "%%F" "%BC_PATH%"

set BUILD_PATH=build-cuda11-trt7
REM Delete build directory
rmdir /s /q %BUILD_PATH%

cmake -G "Visual Studio 16 2019" -DINFERENCE_BACKEND=CUDA -DMY_CUDA_VERSION="11.1" -DMY_TRT_VERSION="7" -B %BUILD_PATH% .
cd %BUILD_PATH%
cmake --build . --config Release -j 34
cmake --install .

rem Move all files from temp folder back to parent folder to restore
for /r "%BC_PATH%\temp" %%F in (*) do copy "%%F" "%BC_PATH%"
rmdir /s /q "%BC_PATH%\temp" 